import 'package:backend.core/core/domain/repositories/app_store_user_to_user_link_repository/repository.dart';
import 'package:backend.core/core/domain/repositories/google_play_user_to_user_link_repository/repository.dart';
import 'package:backend.core/core/domain/repositories/user_repository/repository.dart';

abstract class DeleteUser {
  Future<void> call({
    required String userId,
  });
}

class DeleteUserImpl implements DeleteUser {
  const DeleteUserImpl({
    required AppStoreUserToUserLinkRepository appStoreUserToUserLinkRepository,
    required GooglePlayUserToUserLinkRepository googlePlayUserToUserLinkRepository,
    required UserRepository userRepository,
  })  : _appStoreUserToUserLinkRepository = appStoreUserToUserLinkRepository,
        _googlePlayUserToUserLinkRepository = googlePlayUserToUserLinkRepository,
        _userRepository = userRepository;

  final AppStoreUserToUserLinkRepository _appStoreUserToUserLinkRepository;
  final GooglePlayUserToUserLinkRepository _googlePlayUserToUserLinkRepository;
  final UserRepository _userRepository;

  @override
  Future<void> call({
    required String userId,
  }) async {
    await Future.wait([
      _userRepository.deleteUser(
        userId: userId,
      ),
      _appStoreUserToUserLinkRepository.deleteUserLink(
        userId: userId,
      ),
      _googlePlayUserToUserLinkRepository.deleteUserLink(
        userId: userId,
      ),
    ]);
  }
}
